
from lxc import qw

LOWER_CASE_LETTERS = "abcdefghijklmnopqrstuvwxyz"

MONTH_NAMES = qw("januaray febrary march april may june july august september october november december")

def looseMatch(name, dataset):
    name = filter(lambda e:e in LOWER_CASE_LETTERS, name.lower())
    ret = None
    try:
        ret = dataset.index(name)
    except ValueError:            
        for i, m in enumerate(dataset):
            if m.startswith(name):
                ret = i
                break
    finally:
        return ret    

def getMonth(name):
    return looseMatch(name, MONTH_NAMES)

WEEKDAY_NAMES = qw("sunday monday tuesday wednesday thursday friday saturday")

def getWeekDay(name):
    return looseMatch(name, WEEKDAY_NAMES)
    
